#ifndef __S_ST7789V_H__
#define __S_ST7789V_H__

typedef enum 
{
    s_st7789v_gpio_low = 0,
    s_st7789v_gpio_high
}s_st7789v_gpio_status;

typedef enum
{
    s_st7789v_sleep_enable = 0,
    s_st7789v_sleep_disable
}s_st7789v_sleep_mode;

typedef enum
{
    s_st7789v_display_on = 0,
    s_st7789v_display_off
}s_st7789v_display_mode;

typedef struct
{
    void (*set_rs)(s_st7789v_gpio_status level);
    void (*set_cs)(s_st7789v_gpio_status level);
    void (*set_rd)(s_st7789v_gpio_status level);
    void (*set_wr)(s_st7789v_gpio_status level);
    void (*set_rst)(s_st7789v_gpio_status level);
    void (*set_bl)(s_st7789v_gpio_status level);
    void (*delay)(unsigned int dly);
    void (*write_u16)(unsigned short);
}s_st7789v_t;

// typedef struct
// {
//     s_st7789v_basic_t basic;
//     void (*reset)(void);
// };

typedef enum
{
    s_st7789v_ok = 0,
    s_st7789v_check_failed,
}s_st7789v_status;

extern s_st7789v_status s_st7789v_init(s_st7789v_t *st7789v);
extern void s_st7789v_set_column_addr(s_st7789v_t *st7789v, unsigned short start, unsigned short end);
extern void s_st7789v_set_row_addr(s_st7789v_t *st7789v, unsigned short start, unsigned short end);

#define s_st7789v_set_column_row_addr(t, cs, ce, rs, re)    \
            s_st7789v_set_column_addr(t, cs, ce);\
            s_st7789v_set_row_addr(t, rs, re)

extern void s_st7789v_send_cmd(s_st7789v_t *st7789v, unsigned char cmd);
extern void s_st7789v_send_data(s_st7789v_t *st7789v, unsigned short data);
extern void s_st7789v_fillall(s_st7789v_t *st7789v, unsigned short width, unsigned short height, unsigned short color);

#endif
